Passed
Pull Request — master (#70)
by Mathieu
01:36
created

Quote   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 43
dl 0
loc 45
c 0
b 0
f 0
rs 10

1 Function

Rating   Name   Duplication   Size   Complexity  
A getId 0 3 1
1
import {
2
  Entity,
3
  Column,
4
  PrimaryGeneratedColumn,
5
  ManyToOne,
6
  UpdateDateColumn
7
} from 'typeorm';
8
import {Customer} from '../Customer/Customer.entity';
9
import {Project} from '../Project/Project.entity';
10
import {User} from '../User/User.entity';
11
12
@Entity()
13
export class Quote {
14
  public static readonly STATUS_DRAFT = 'draft';
15
  public static readonly STATUS_SENT = 'sent';
16
  public static readonly STATUS_REFUSED = 'refused';
17
  public static readonly STATUS_ACCEPTED = 'accepted';
18
  public static readonly STATUS_CANCEL = 'canceled';
19
20
  @PrimaryGeneratedColumn('uuid')
21
  private id: string;
22
23
  @Column({type: 'varchar', nullable: false})
24
  private status: string;
25
26
  @Column({type: 'varchar', nullable: false, unique: true})
27
  private quoteId: string;
28
29
  @Column({type: 'timestamp', default: () => 'CURRENT_TIMESTAMP'})
30
  private createdAt: Date;
31
32
  @ManyToOne(type => User, {nullable: false})
33
  private owner: User;
34
35
  @ManyToOne(type => Customer, {nullable: false})
36
  private customer: Customer;
37
38
  @ManyToOne(type => Project, {nullable: true})
39
  private project: Project;
40
41
  constructor(
42
    quoteId: string,
43
    owner: User,
44
    customer: Customer,
45
    project?: Project | null
46
  ) {
47
    this.quoteId = quoteId;
48
    this.owner = owner;
49
    this.customer = customer;
50
    this.project = project;
51
    this.status = Quote.STATUS_DRAFT;
52
  }
53
54
  public getId(): string {
55
    return this.id;
56
  }
57
}
58